<?php
/**
 * Description of Test
 *
 * @author Damiano Ciarla
 */
class loadRouter implements BXD_Event_Interface_Listener
{
	public function onAction($paramsEvent)
	{
		Bxd::includePlugin()->router();

		$router = Router::getInstance();

		$router->route("home", "/home", "Home", "index")->redirect301("http://www.google.it");
		$router->route("community", "/community(/<#page>)", "Community", "index");
		$router->route("profile", "/profile/<:username>", "User", "profile");

		$result = $router->match($paramsEvent['url']);

		if($result)
		{
			foreach($result as $key => $value)
			{
				switch($key)
				{
					case "controller":
						Bxd::getInstance()->bxdConf()->controller = $value;
						break;

					case "action":
						Bxd::getInstance()->bxdConf()->action = $value;
						break;

					default:
						Bxd::getInstance()->bxdConf()->params[$key] = $value;
						break;
				}
			}
		}
	}
}
?>
